package data;

import java.io.File;
import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.ObjectOutputStream;
import java.rmi.Naming;
import java.rmi.RemoteException;
import java.rmi.registry.LocateRegistry;
import java.rmi.server.UnicastRemoteObject;

import po.CoursePo;
import po.UserPo;

public class Start extends UnicastRemoteObject {

	private static final long serialVersionUID = 1L;

	protected Start() throws RemoteException {
		super();
		// TODO Auto-generated constructor stub
	}

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		try {
			File file7 = new File("time.txt");
			if (!file7.exists()) {
				file7.createNewFile();
				FileWriter fw = new FileWriter(file7);
		     	fw.write("1 1" + "\r\n");
				fw.close();
			}
			File file3 = new File("allplan1.txt");
			if (!file3.exists()) {
				file3.createNewFile();
			}
			File file4 = new File("Chinese1.txt");
			if (!file4.exists()) {
				file4.createNewFile();
			}
			File file5 = new File("math1.txt");
			if (!file5.exists()) {
				file5.createNewFile();
			}
			File file6 = new File("English1.txt");
			if (!file6.exists()) {
				file6.createNewFile();
			}

			File file1 = new File("userList.txt");
			if (!file1.exists()) {
				file1.createNewFile();
				ObjectOutputStream oos1 = new ObjectOutputStream(
						new FileOutputStream(file1));
				UserPo userNull = null;
				oos1.writeObject(userNull);
				oos1.close();
			}

			File file2 = new File("courseList1.txt");
			if (!file2.exists()) {
				file1.createNewFile();
				ObjectOutputStream oos2 = new ObjectOutputStream(
						new FileOutputStream(file2));
				CoursePo courseNull = null;
				oos2.writeObject(courseNull);
				oos2.close();
			}
			AllPlanData allPlan = new AllPlanData();
			EduPlanData eduPlan = new EduPlanData();
			CourseData course = new CourseData();
			UserData user = new UserData();
			SelectCourseData selectCourse = new SelectCourseData();
			LocateRegistry.createRegistry(7777);
			Naming.bind("//localhost:7777/allPlan", allPlan);
			Naming.bind("//localhost:7777/eduPlan", eduPlan);
			Naming.bind("//localhost:7777/course", course);
			Naming.bind("//localhost:7777/user", user);
			Naming.bind("//localhost:7777/selectCourse", selectCourse);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

	}

}
